import tensorflow as tf


# a = tf.constant([1.0, 2.0], name="a")
# b = tf.constant([2.0, 3.0], name="b")
#
# result2 = a + b
#
#
# print(result2)
#
# print(tf.global_variables())


w1 = tf.Variable(tf.random_normal([2, 3], stddev=1))
w2 = tf.Variable(tf.random_normal([3, 1], stddev=1))

x = tf.placeholder(tf.float32, shape=(1, 2), name="input")

a = tf.matmul(x, w1)
y = tf.matmul(a, w2)

y = tf.sigmoid(y)
# 交叉熵
# cross_entropy = -tf.reduce_mean(y_ * tf.log(tf.clip_by_value(y, 1e-10, 1.0) + (1-y)*tf.log((1-y), 1e-10, 1.0)))
with tf.Session() as sess:
    init_op = tf.global_variables_initializer();
    sess.run(init_op)
    print(sess.run(y, feed_dict={x: [[0.7, 0.9]]}))
